package com.qd.panda.gas.base;

import com.fasterxml.jackson.databind.JsonNode;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Optional;

@Data
@Accessors(chain = true)
public class BaseHttpResponseDTO {
    private static final Integer SUCCESS_CODE = 200;
    /**
     * 是否成功
     */
    public boolean isSuccess() {
        return Optional.ofNullable(errCode).orElse(0).equals(SUCCESS_CODE);
    }

    /**
     * 错误编码
     */
    private Integer errCode;

    /**
     * 错误值
     */
    private String errMsg;

    /**
     * 具体数据
     */
    private JsonNode data;

    public void freeData(){
        this.errCode = null;
        this.errMsg = null;
        this.data = null;
    }
}